package com.ly.demo.scheduled;

import cn.hutool.json.JSONUtil;
import com.ly.demo.entity.KafkaVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.stereotype.Component;

import static com.ly.demo.utils.Constant.BAAS_CONTACT_USER_NOTICE;

/**
 * @Author liuyang
 * @Date 2024/3/15 17:59
 **/
@Slf4j
@Component
public class KafkaListenerTask {
    //@KafkaListener(topics = BAAS_CONTACT_USER_NOTICE,groupId = "your-group-id")
    public void addNode(ConsumerRecord<String, String> record, Acknowledgment ack) {
        ack.acknowledge();
        String value = record.value();
        KafkaVo kafkaVo = JSONUtil.toBean(value, KafkaVo.class);
        System.out.println(kafkaVo.getData());
    }
}
